package com.itranswarp.learnjava;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.util.logging.Logger;

/**
 * Learn Java from https://www.liaoxuefeng.com/
 * 
 * @author liaoxuefeng
 */
public class Main {

	public static void main(String[] args) {
		Log log = LogFactory.getLog(Main.class);
		log.info("Hello World");
        try {
            System.out.println(tax(2000, 0.1));
            System.out.println(tax(-200, 0.1));
            System.out.println(tax(2000, -0.1));
        } catch (Exception e) {
			log.error("error!",e);
        }

    }

	static double tax(int salary, double rate) {
		// TODO: 如果传入的参数为负，则抛出IllegalArgumentException
		if (salary <= 0 || rate <= 0) {
			throw new IllegalArgumentException("Salary and Rate should be greater than 0");
		}
		return salary * rate;
	}
}
